import type { HttpMethod } from './enums';
import { AxiosResponse } from 'axios/index';

export interface IRequestOption<T> {
  method: HttpMethod;
  route: string;
  requestObj?: T;
  headers?: Record<string, string | undefined>;
  widthCredentials?: boolean;
}

export interface ResponseSuccess {
  success: boolean;
}

export interface BaseDTO {
  errors?: ApiValidationError[];
  message: string;
  statusCode: number;
  _metadata: BaseMetadataDTO;
}

export interface BaseMetadataDTO {
  languages: string[];
  path: string;
  repoVersion: string;
  requestId: string;
  timestamp: number;
  timezone: string;
  version: string;
}

export interface BaseMetadataWithPaginationDTO<T> extends BaseMetadataDTO {
  pagination: {
    filters: T;
    search: '';
    availableSearch: ['name'];
    page: 1;
    perPage: 20;
    orderBy: 'createdAt';
    orderDirection: 'asc';
    availableOrderBy: ['name', 'createdAt'];
    availableOrderDirection: ['asc', 'desc'];
    total: 4;
    totalPage: 1;
  };
}

export type WithError<T> = { data: T | null; err: AxiosResponse<T> | null };

export type ApiValidationError = {
  property: string;
  message: string;
};

export interface responseRefreshDTO extends BaseDTO {
  data: {
    accessToken: string;
    expiresIn: number;
    refreshToken: string;
    roleType: string;
    tokenType: string;
  };
}
